package cate.game.role.pvp.minecraft;

import cate.common.table.d.GDFunc;
import cate.game.role.FuncOpenChecker;
import cate.game.role.Role;
import cate.game.role.pvp.minecraft.msg.MinecraftMineAreaStateResp;
import cate.game.role.pvp.minecraft.po.MinecraftChallengePO;
import cate.game.role.pvp.minecraft.po.MinecraftGatherPO;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass("矿洞争霸")
public class MyMinecraftPO extends FuncOpenChecker {
    @NoteField("挑战数据")
    public MinecraftChallengePO challengePO;
    @NoteField("采集数据")
    public MinecraftGatherPO gatherPO;

    @Override
    public void initialize(Role role) {
        super.initialize(role);
        if (challengePO == null) {
            challengePO = new MinecraftChallengePO();
        }
        challengePO.initialize(role);
        if (gatherPO == null) {
            gatherPO = new MinecraftGatherPO();
        }
        gatherPO.initialize(role);
    }


    @Override
    public void onEnter() {
        super.onEnter();
        challengePO.onEnter();
    }

    @Override
    public int getFuncId() {
        return GDFunc.MINECRAFT;
    }

    @Override
    public void onAfterOpen() {
        challengePO.onAfterOpen();
        gatherPO.onAfterOpen();
    }

    @Override
    public void onDaySpan(boolean silence) {
        super.onDaySpan(silence);
        gatherPO.onDaySpan(silence);
    }

    @Override
    protected void offline() {
        super.offline();
        gatherPO.offline();
    }

    /**
     * 发送矿洞争霸-采矿区开关状态
     */
    public void sendMinecraftMineAreaState() {
        role.sendNow(new MinecraftMineAreaStateResp(role.getGame().pvp.minecraft.isClosed(),
                role.getGame().pvp.minecraft.getOpenTime(),
                role.getGame().pvp.minecraft.getCloseTime()));
    }
}
